package rbtree;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:咭咭熊
 * Date:2021 - 08 - 28
 * Time:15:37
 */

/***
 * 简单定义红黑树中树的节点
 * 不写key-value形式，只写纯key形式
 * key的类型固定成long类型
 */
public class RBTreeNode {
    /***
     * 定义常量
     */
    public static  final boolean BLACK = true;
    public static  final boolean RED= false;
    /***
     * 1.key类型
     */
    public long key;

    /***
     * 2.节点的左右孩子
     */
    public RBTreeNode left;
    public RBTreeNode right;

    /***
     * 3.该节点的父节点，如果是null,则说明该节点是树的根节点
     */
    public  RBTreeNode parent;

    /***
     * 4.节点的颜色
     */
    public boolean color;

    public RBTreeNode(long key,RBTreeNode parent,boolean color){
        this.key = key;
        this.left = this.right = null;
        this.color = color;
    }

    @Override
    public String toString() {
        return "RBTreeNode{" +
                "key=" + key +
                ", color=" + (color == BLACK ? "黑色":"红色") +
                '}';
    }
}
